using System.Web;
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
using DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;

	/// <summary>
	/// Strong-typed bag of session state.
	/// </summary>
public class State {
    public static ClaimsResponse ProfileFields {
        get { return HttpContext.Current.Session["ProfileFields"] as ClaimsResponse; }
        set { HttpContext.Current.Session["ProfileFields"] = value; }
    }

    public static string FriendlyLoginName {
        get { return HttpContext.Current.Session["FriendlyUsername"] as string; }
        set { HttpContext.Current.Session["FriendlyUsername"] = value; }
    }

    public static string UniqueId {
        get { return HttpContext.Current.Session["UniqueId"] as string; }
        set { HttpContext.Current.Session["UniqueId"] = value; }
    }

    public static string UsableFriendlyLoginName {
        get {
            ClaimsResponse fields = ProfileFields;
            if (fields == null) return string.Empty;
            if (!string.IsNullOrEmpty(fields.Nickname)) return fields.Nickname;
            if (!string.IsNullOrEmpty(fields.FullName)) return fields.FullName;
            if (!string.IsNullOrEmpty(fields.Email)) return fields.Email;
            return FriendlyLoginName;
        }
    }
    public static void Clear() {
        ProfileFields = null;
        FriendlyLoginName = null;
    }
}